﻿using System.Collections;
using System.Collections.Generic;
using LitJson;
using UnityEngine;

public class ReplyAddFriendRequest : BaseRequest
{
	private ReplyAddFriendPanel _replyAddFriendPanel;
	
	protected override void Awake()
	{
		_controllerType = ControllerType.USER;
		_methodType = MethodType.REPLY_ADD_FRIEND;
		base.Awake();
	}

	// Use this for initialization
	void Start () {
		//组件初始化
		_replyAddFriendPanel = this.gameObject.GetComponent<ReplyAddFriendPanel>();

	}
	
	// Update is called once per frame
	void Update () {
		
	}
	public void SendRequest(int friendId, int status)
	{
		JsonData requestJsonData = new JsonData();
		requestJsonData["friendId"] = friendId;
		requestJsonData["status"] = status;
		NettyRequest nettyRequest = new NettyRequest();
		nettyRequest.controllerType = (int) _controllerType;
		nettyRequest.methodType = (int) _methodType;
		nettyRequest.data = requestJsonData.ToJson();
		byte[] dataBytes = ConverterTool.SerialRequestObj(nettyRequest);
		UnityFacade.Instance.ClientManager.SendMsgToServer(dataBytes);
	}
	
	public override void OnResponse(string data)
	{
		JsonData respJsonData = JsonMapper.ToObject(data);
		_replyAddFriendPanel.HandleResponse(respJsonData);

	}

}
